// AlarmDataManager.h: interface for the AlarmDataManager class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_ALARMDATAMANAGER_H__00624605_32F0_4792_A993_F6792CEC0213__INCLUDED_)
#define AFX_ALARMDATAMANAGER_H__00624605_32F0_4792_A993_F6792CEC0213__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

class AlarmData;
class BaseCoalMineUnit;
class BaseMonitoringUnit;
class AlarmThread;

class AlarmDataManager  
{
protected:
	AlarmDataManager();
	virtual ~AlarmDataManager();

public:
	static AlarmDataManager * Instance();
  static void DeleteInstance();

  // Implementations
  void Init();
  void Cleanup();
  AlarmThread * CreateAlarmThread();
  void DestroyAlarmThread();
  const std::list<AlarmData *>& GetAlarmDatas() const {return m_AlarmDatas;}
  AlarmData * NewAlarmData(long nCoalMineId, const CString& strId);
  void AddAlarmData(AlarmData * pAlarmData);
  void DeleteAlarmData(AlarmData * pAlarmData);
  void DeleteAllAlarmDatas();
  void DeleteUndefinedAlarmDatas(CListCtrl& listctrl);
  AlarmData * GetAlarmData(long nCoalMineId, const CString& strId);
  void UpdateAlarmData(BaseCoalMineUnit * pCoalMineUnit, BaseMonitoringUnit * pMonitoringUnit, CListCtrl * pListCtrl);
  void BuildAllAlarmDatas(CListCtrl& listctrl);
  bool GetVoiceAlarmText(CString& strAlarmText);

  // UI utilities
  HTREEITEM InsertToTreeCtrl(CTreeCtrl& treectrl, HTREEITEM hItemParent) const;
  int InsertToListCtrl(CListCtrl& listctrl) const;
  void UpdateInListCtrl(CListCtrl& listctrl, AlarmData * pAlarmData, bool bDelete = false) const;

protected:
  std::list<AlarmData *> m_AlarmDatas;
  AlarmThread * m_pAlarmThread;
  CMutex m_mutexAlarmData;

private:
  static AlarmDataManager * m_pInstance;
};

#endif // !defined(AFX_ALARMDATAMANAGER_H__00624605_32F0_4792_A993_F6792CEC0213__INCLUDED_)
